var status = -1;
var selectionLog = [];
var items = [1402199, 1492181, 1242065, 1372179, 1322205, 1472216, 1312155, 1582039, 1532100, 1052612, 1132228, 1382211, 1302277, 1332227, 1012376, 1003863, 1113034, 1122252, 1462195, 1442225, 1522096, 1422142, 1482170, 1232060, 1212066, 1102562, 1362092, 1452207, 1412137, 1432169, 1222061];

function start() {
    action(1, 0, 0)
}

function action(e, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && e == 0) {
        im.dispose();
        return
    }(e == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            var d = "想要兑换哪一件武器？\r\n#b";
            for (var a = 0; a < items.length; a++) {
                d += "#L" + a + "##i" + items[a] + "##z" + items[a] + "##l\r\n"
            }
            im.askMenu(d)
        } else {
            if (status === a++) {
                im.dispose();
                var f = im.getItemId();
                im.gainItem(items[b], 1);
                im.gainItem(f, -1)
            }
        }
    }
};